import Taro from '@tarojs/taro';
import {getCircularIconApi} from './api.js'

export default {
    namespace: 'picture',
    state: {
        circularIcon: []
    },
  
    effects: {
        /**
         * 获取圆形图标
         * @param {*} param0 
         * @param {*} param1 
         */
        *getCircularIcon({ payload }, { call, put,select }){
            try {
                let provide = payload
                const puzzle = yield call(getCircularIconApi,provide)
                if(puzzle.code === 200){
                    yield put({type:'synCircularIcon',payload:puzzle.data})
                }else{
                    console.log(puzzle.message);
                }
                console.log(puzzle,'getCircularIcon');

            } catch (error) {
                console.log(JSON.stringify(error));
            }
        }
    },
  
    reducers: {
      save(state, { payload }) {
        return { ...state, ...payload };
      },
      /**
       * 同步圆形图标
       */
      synCircularIcon(state, { payload:vlaues }) {
        const circularIcon = vlaues
        return {
          ...state,
          circularIcon
        }
      }
    },
  };